#pragma once
class ZMTriangelGroup
{
public:
	ZMTriangelGroup() {};
	ZMTriangelGroup(const ZMVector<ZMPoint3D>& vPnt, const ZMVector<int>& vInx);
	~ZMTriangelGroup();

	void InsertData(const ZMTriangelGroup& group, bool isPlus = false)
	{
		InsertData(group.m_vPnt, group.m_vInx, isPlus);
	}

	void InsertData(const ZMVector<ZMPoint3D>& vPnt, const ZMVector<int>& vInx, bool isPlus = false)
	{
		int iPlusNum = 0;
		if(isPlus)
		{
			iPlusNum = m_vPnt.size();
		}
		InsertPnt(vPnt);
		InsertInx(vInx, iPlusNum);
	}

	void InsertPnt(const ZMVector<ZMPoint3D>& vPnt)
	{
		m_vPnt.insert(m_vPnt.end(), vPnt.begin(), vPnt.end());
	}

	void InsertInx(const ZMVector<int>& vInx, int iPlusNum = 0)
	{
		for (int inx : vInx)
		{
			m_vInx.push_back(inx + iPlusNum);
		}
	}

	void Clear()
	{
		m_vPnt.clear();
		m_vInx.clear();
	}

	void WriteData(CFileSaveData& fp);

	void WriteData(CStreamSaveData& fp);

	bool GetHeight(const ZMReal& x, const ZMReal& y, ZMReal& z) const;

	ZMVector<ZMPoint3D> m_vPnt;

	ZMVector<int> m_vInx;
private:
	int GetHeight(const ZMTriangle&tri, const  ZMReal& x, const ZMReal& y, ZMReal& z) const;
};

